package com.team.hiring.common.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class CutAndCopy {
	public void cut(String url, String url2) throws IOException {

		File file = new File(url);
		File file2 = new File(url2);
		FileInputStream fileInputStream = new FileInputStream(file);
		FileOutputStream fileOutputStream = new FileOutputStream(file2);
		byte[] buffer = new byte[1024];
		int len = 0;
		while ((len = fileInputStream.read(buffer)) != -1) {
			fileOutputStream.write(buffer, 0, len);
		}
		fileInputStream.close();
		fileOutputStream.close();
		file.delete();
		System.out.println("剪切成功！，" + file + "已剪切到" + file2);
	}

	public void copy(String url, String url2) throws IOException {

		File file = new File(url);
		File file2 = new File(url2);
		FileInputStream fileInputStream = new FileInputStream(file);
		FileOutputStream fileOutputStream = new FileOutputStream(file2);
		byte[] buffer = new byte[1024];
		int len = 0;
		while ((len = fileInputStream.read(buffer)) != -1) {
			fileOutputStream.write(buffer, 0, len);
		}
		fileInputStream.close();
		fileOutputStream.close();
		System.out.println("复制成功！，" + file + "已复制到" + file2);
	}
}
